package com.cjb.cloudsystem.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjb.cloudsystem.entity.SysLogOperate;
import com.cjb.cloudsystem.mapper.SysLogOperateMapper;
import com.cjb.cloudsystem.service.SysLogOperateService;
import com.cjb.cloudsystem.vo.SysLogOperateVO;
import com.cjb.common.mybatisUtil.impl.BaseRepositoryImpl;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
* @Author chenjinbin
* @Package IntelliJ IDEA
* @Class SysLogOperatesServiceImpl
* @Date 2023-07-27 21:41
*/
@Service
@AllArgsConstructor
public class SysLogOperateRepositoryImpl extends BaseRepositoryImpl<SysLogOperateMapper, SysLogOperate> implements SysLogOperateService {
/**
* 日志
*/
    private final static Logger log = LoggerFactory.getLogger(SysLogOperateRepositoryImpl.class);
    /*
    * 注入mapper层
    */
    private final SysLogOperateMapper sysLogOperateMapper;
    /**
     * 单体保存
     *
     * @return
     * @Author chenjinbin
     * @Value
     * @Title
     */
    @Override
    public boolean save(SysLogOperate sysLogOperate) {
        baseMapper.insert(sysLogOperate);
        return true;
    }

    /**
    *批量保存
    *
    * @Author chenjinbin
    * @Value
    * @Title
    */
    @Override
    public Integer listSave(List<SysLogOperate> sysLogOperate) {
        return sysLogOperateMapper.insertBatchSomeColumn(sysLogOperate);
    }

    /**
    * 批量更新
    *
    * @Author chenjinbin
    * @Value
    * @Title
    */
    @Override
    public void listUpdate(List<SysLogOperate> sysLogOperate) {
        sysLogOperateMapper.insertBatchSomeColumn(sysLogOperate);
    }

    /**
    * 批量删除
    *
    * @Author chenjinbin
    * @Value
    * @Title
    */
    @Override
    public void listDelete(List<SysLogOperate> sysLogOperate) {
        List<Long> collect = sysLogOperate.stream().map(SysLogOperate::getId)
        .distinct()
        .collect(Collectors.toList());
        sysLogOperateMapper.deleteBatchIds(collect);
    }
    /**
    * 通过id删除
    *
    * @Author chenjinbin
    * @Value
    * @Title
    */
    @Override
    public int deleteById(SysLogOperate sysLogOperate) {
    return sysLogOperateMapper.deleteById(sysLogOperate.getId());
    }

    /**
    *单个查询
    *
    * @Author chenjinbin
    * @Value
    * @Title
    */
    @Override
    public SysLogOperate queryById(SysLogOperate sysLogOperate) {
        return  sysLogOperateMapper.selectById(sysLogOperate.getId());
    }

    @Override
    public Page queryPage(Page sysLogOperatePage , SysLogOperateVO sysLogOperate) {
        return sysLogOperateMapper.selectPage(sysLogOperatePage, null);
    }

    /**
    * 返回全部信息
    *
    * @Author chenjinbin
    * @Value
    * @Title
    */
    @Override
    public List<SysLogOperate> returnAllData() {
        return sysLogOperateMapper.selectList(null);
    }

}